/**
 * website
 * com.inmaytide.website.utils
 * ReflectUtils.java
 * May 26, 2016 2:08:16 PM
 */
package com.inmaytide.website.utils;

import org.apache.commons.lang3.reflect.FieldUtils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author luomiao
 * @since May 26, 2016
 */
public class ReflectUtils {

    public static List<Field> findFieldsByAnnotation(Class<?> cls, Class<? extends Annotation> annotationClass) {
        return FieldUtils.getAllFieldsList(cls).stream()
                .filter(f -> f.isAnnotationPresent(annotationClass)).collect(Collectors.toList());
    }

}
